<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>53数组去重若干方法2</title>
</head>
<body>

<script>
  let arr = [1, 2, 3, 4, 44, 42, 21, 3, 3, 2, 4, 5, 5, 3, 2, 2]

  function uniqueArr(array) {
    return array.sort(function (a, b) {
      return a - b
    }).reduce(function (prev,item) {
      if (prev.length === 0 || prev[prev.length - 1] !== item){
        prev.push(item)
      }
      return prev

    },[]);
  }


  console.log(uniqueArr(arr));


</script>
</body>
</html>